package github.kawaiior.yuanchuxiuzhen.common.world.gen;

import github.kawaiior.yuanchuxiuzhen.core.init.StructureInit;
import github.kawaiior.yuanchuxiuzhen.core.init.BiomeInit;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.event.world.BiomeLoadingEvent;

import java.util.List;
import java.util.Set;
import java.util.function.Supplier;

public class ModStructureGeneration {

    public static void generateStructures(final BiomeLoadingEvent event) {
        RegistryKey<Biome> key = RegistryKey.getOrCreateKey(Registry.BIOME_KEY, event.getName());
        List<Supplier<StructureFeature<?, ?>>> structures = event.getGeneration().getStructures();
        Set<BiomeDictionary.Type> types = BiomeDictionary.getTypes(key);

        if(types.contains(BiomeDictionary.Type.PLAINS)) {
            // other structure
//            structures.add(() -> StructureInit.STRUCTURE_02.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
//            structures.add(() -> StructureInit.STRUCTURE_03.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
            structures.add(() -> StructureInit.STRUCTURE_09.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
        }

        // Check if the current biome is your custom biome.
        if(key.equals(BiomeInit.HEAVEN)) {
            structures.add(() -> StructureInit.STRUCTURE_01.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
            structures.add(() -> StructureInit.STRUCTURE_04.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
            structures.add(() -> StructureInit.STRUCTURE_10.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
        }
    }

}
